package cn.yuanqiao.web.controller.cqbc;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;
import cn.yuanqiao.cqbc.inspection.domain.RegularInspections;
import cn.yuanqiao.cqbc.inspection.service.IRegularInspectionsService;
import cn.yuanqiao.common.core.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.core.page.TableDataInfo;

/**
 * 巡检定时任务Controller
 * 
 * @author xy
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/cqbc/regularInspections")
public class RegularInspectionsController extends BaseController
{
    @Autowired
    private IRegularInspectionsService regularInspectionsService;

    /**
     * 查询巡检定时任务列表
     */
   // @RequiresPermissions("cqbc:regularInspections:list")
    @GetMapping("/list")
    public TableDataInfo list(RegularInspections regularInspections)
    {
        startPage();
        List<RegularInspections> list = regularInspectionsService.selectRegularInspectionsList(regularInspections);
        return getDataTable(list);
    }

    /**
     * 导出巡检定时任务列表
     */
  //  @RequiresPermissions("cqbc:regularInspections:export")
    @Log(title = "巡检定时任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RegularInspections regularInspections)
    {
        List<RegularInspections> list = regularInspectionsService.selectRegularInspectionsList(regularInspections);
        ExcelUtil<RegularInspections> util = new ExcelUtil<RegularInspections>(RegularInspections.class);
        util.exportExcel(response, list, "巡检定时任务数据");
    }

    /**
     * 获取巡检定时任务详细信息
     */
   // @RequiresPermissions("cqbc:regularInspections:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(regularInspectionsService.selectRegularInspectionsById(id));
    }

    /**
     * 新增巡检定时任务
     */
   // @RequiresPermissions("cqbc:regularInspections:add")
    @Log(title = "巡检定时任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RegularInspections regularInspections)
    {
        return toAjax(regularInspectionsService.insertRegularInspections(regularInspections));
    }

    /**
     * 修改巡检定时任务
     */
 //   @RequiresPermissions("cqbc:regularInspections:edit")
    @Log(title = "巡检定时任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RegularInspections regularInspections)
    {
        return toAjax(regularInspectionsService.updateRegularInspections(regularInspections));
    }

    /**
     * 删除巡检定时任务
     */
 //   @RequiresPermissions("cqbc:regularInspections:remove")
    @Log(title = "巡检定时任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(regularInspectionsService.deleteRegularInspectionsByIds(ids));
    }
}
